using System.Data;
using System.Data.SqlClient;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;


namespace THANHTUNGO.Portal.Modules.DISCUSSION.Components
{
    public class Item
    {
        public static DataSet GetTopLevel(int moduleID)
        {
            string spName = "[dbo].p_DISCUSSION_Item_GetTopLevel";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);
            db.AddInParameter(dbCommand, "@ModuleID", SqlDbType.Int, moduleID);
            return db.ExecuteDataSet(dbCommand);
        }

        public static DataSet GetThreadMessages(int itemID, char showRoot)
        {
            string spName = "[dbo].[p_DISCUSSION_Item_GetThreadMessages]";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);
            db.AddInParameter(dbCommand, "@ID", SqlDbType.Int, itemID);
            db.AddInParameter(dbCommand, "@IncludeRoot", SqlDbType.Char, showRoot);
            return db.ExecuteDataSet(dbCommand);        
        }
    }
}
